class UsersController < ApplicationController
	before_action :set_user, only: [:show, :edit, :update, :destroy]

  def index
  	@users = User.all
  end

  def edit
  	
  end

  def new
  	@user = User.new
  end

  def create
  	  @user = User.new(user_params)
  	  
  	  respond_to do |format|
  	  	if @user.save
  	  		format.html { redirect_to @user, notice: 'User successfully added!' }
  	  	else
  	  		format.html { render action: 'new' }
  	  	end
  	  end
  end

  def update
  	if @user.update(user_params)
  		redirect_to @user, notice: "User successfully updated!" 
  	else
  		render action: "edit"
  	end
  end

  def destroy
  	respond_to do |format|
 	 	@user.destroy
 	 	format.html { redirect_to users_url }
 	end
  end

  def show
  end

  private

  def user_params
  	params.require(:user).permit(:first_name, :last_name, :email_address, :password, :password_confirmation)
  end

  def set_user
  	@user = User.find(params[:id])
  end

end
